package com.mec.ServerCluser.core;

import java.util.Objects;

/**
 * 注册中心中存储起来的应用服务器的信息
 */
public class AppServerDefination {
    private String serverIp;
    private int serverPort;
    private int responseTime;

    public AppServerDefination(String serverIp, int serverPort) {
        this.serverIp = serverIp;
        this.serverPort = serverPort;
    }


    public boolean equals(AppServerDefination asd) {
        return this.serverIp.equals(asd.getServerIp()) && this.serverPort == asd.getServerPort();
    }
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        AppServerDefination that = (AppServerDefination) o;
        return serverPort == that.serverPort &&
                Objects.equals(serverIp, that.serverIp);
    }

    @Override
    public int hashCode() {
        return Objects.hash(serverIp, serverPort);
    }

    public String getServerIp() {
        return serverIp;
    }

    public void setServerIp(String serverIp) {
        this.serverIp = serverIp;
    }

    public int getServerPort() {
        return serverPort;
    }

    public void setServerPort(int serverPort) {
        this.serverPort = serverPort;
    }

    public int getResponseTime() {
        return responseTime;
    }

    public void setResponseTime(int responseTime) {
        this.responseTime = responseTime;
    }

    @Override
    public String toString() {
        return "AppServerDefination{" +
                "serverIp='" + serverIp + '\'' +
                ", serverPort=" + serverPort +
                ", responseTime=" + responseTime +
                '}';
    }
}
